﻿using System.IO;
using Actya.Web.Infrastructure.ElFinderConnector.Responses;

namespace Actya.Web.Infrastructure.ElFinderConnector.Commands
{
    public class Init : ICommand
    {
        #region ICommand Members

        public Response Execute()
        {
			if (! Directory.Exists(Configuration.Configuration.RootPath))
			{
				Directory.CreateDirectory(Configuration.Configuration.RootPath);
			}
            var folder = new Utils.Folder(Configuration.Configuration.RootPath);

            var response = new InitResponse();

            response.cwd = folder.Cwd;

            response.cdc = folder.Contents;

            response.tree = folder.Tree;

            return response;
        }

        #endregion
    }
}
